/* USER CODE BEGIN Header */
/**
  ******************************************************************************
  * File Name          : freertos.c
  * Description        : Code for freertos applications
  ******************************************************************************
  * @attention
  *
  * Copyright (c) 2023 STMicroelectronics.
  * All rights reserved.
  *
  * This software is licensed under terms that can be found in the LICENSE file
  * in the root directory of this software component.
  * If no LICENSE file comes with this software, it is provided AS-IS.
  *
  ******************************************************************************
  */
/* USER CODE END Header */

/* Includes ------------------------------------------------------------------*/
#include "FreeRTOS.h"
#include "task.h"
#include "main.h"
#include "cmsis_os.h"

/* Private includes ----------------------------------------------------------*/
/* USER CODE BEGIN Includes */

/* USER CODE END Includes */

/* Private typedef -----------------------------------------------------------*/
/* USER CODE BEGIN PTD */

/* USER CODE END PTD */

/* Private define ------------------------------------------------------------*/
/* USER CODE BEGIN PD */

/* USER CODE END PD */

/* Private macro -------------------------------------------------------------*/
/* USER CODE BEGIN PM */

/* USER CODE END PM */

/* Private variables ---------------------------------------------------------*/
/* USER CODE BEGIN Variables */

/* USER CODE END Variables */
/* Definitions for defaultTask */
osThreadId_t defaultTaskHandle;
const osThreadAttr_t defaultTask_attributes = {
  .name = "defaultTask",
  .stack_size = 128 * 4,
  .priority = (osPriority_t) osPriorityNormal,
};
/* Definitions for LED_TASK */
osThreadId_t LED_TASKHandle;
const osThreadAttr_t LED_TASK_attributes = {
  .name = "LED_TASK",
  .stack_size = 64 * 4,
  .priority = (osPriority_t) osPriorityLow,
};
/* Definitions for Chassis_TASK */
osThreadId_t Chassis_TASKHandle;
const osThreadAttr_t Chassis_TASK_attributes = {
  .name = "Chassis_TASK",
  .stack_size = 512 * 4,
  .priority = (osPriority_t) osPriorityRealtime,
};
/* Definitions for Communicatetask */
osThreadId_t CommunicatetaskHandle;
const osThreadAttr_t Communicatetask_attributes = {
  .name = "Communicatetask",
  .stack_size = 256 * 4,
  .priority = (osPriority_t) osPriorityRealtime,
};
/* Definitions for LostCountertask */
osThreadId_t LostCountertaskHandle;
const osThreadAttr_t LostCountertask_attributes = {
  .name = "LostCountertask",
  .stack_size = 256 * 4,
  .priority = (osPriority_t) osPriorityRealtime1,
};
/* Definitions for DataTest_Task */
osThreadId_t DataTest_TaskHandle;
const osThreadAttr_t DataTest_Task_attributes = {
  .name = "DataTest_Task",
  .stack_size = 128 * 4,
  .priority = (osPriority_t) osPriorityRealtime,
};
/* Definitions for DrawUI_Task */
osThreadId_t DrawUI_TaskHandle;
const osThreadAttr_t DrawUI_Task_attributes = {
  .name = "DrawUI_Task",
  .stack_size = 128 * 4,
  .priority = (osPriority_t) osPriorityLow,
};
/* Definitions for SuperC_Task */
osThreadId_t SuperC_TaskHandle;
const osThreadAttr_t SuperC_Task_attributes = {
  .name = "SuperC_Task",
  .stack_size = 128 * 4,
  .priority = (osPriority_t) osPriorityBelowNormal,
};
/* Definitions for Remote_Task */
osThreadId_t Remote_TaskHandle;
const osThreadAttr_t Remote_Task_attributes = {
  .name = "Remote_Task",
  .stack_size = 128 * 4,
  .priority = (osPriority_t) osPriorityRealtime,
};
/* Definitions for ImuTask */
osThreadId_t ImuTaskHandle;
const osThreadAttr_t ImuTask_attributes = {
  .name = "ImuTask",
  .stack_size = 256 * 4,
  .priority = (osPriority_t) osPriorityHigh6,
};
/* Definitions for RemoteSem */
osSemaphoreId_t RemoteSemHandle;
const osSemaphoreAttr_t RemoteSem_attributes = {
  .name = "RemoteSem"
};

/* Private function prototypes -----------------------------------------------*/
/* USER CODE BEGIN FunctionPrototypes */

/* USER CODE END FunctionPrototypes */

void StartDefaultTask(void *argument);
void LEDTask(void *argument);
void ChassisTask(void *argument);
void CommunicateTask(void *argument);
void LostCounterTask(void *argument);
void DataTestTask(void *argument);
void DrawUITask(void *argument);
void SuperCTask(void *argument);
void RemoteTask(void *argument);
void GyroTask(void *argument);

void MX_FREERTOS_Init(void); /* (MISRA C 2004 rule 8.1) */

/**
  * @brief  FreeRTOS initialization
  * @param  None
  * @retval None
  */
void MX_FREERTOS_Init(void) {
  /* USER CODE BEGIN Init */

  /* USER CODE END Init */

  /* USER CODE BEGIN RTOS_MUTEX */
  /* add mutexes, ... */
  /* USER CODE END RTOS_MUTEX */

  /* Create the semaphores(s) */
  /* creation of RemoteSem */
  RemoteSemHandle = osSemaphoreNew(1, 1, &RemoteSem_attributes);

  /* USER CODE BEGIN RTOS_SEMAPHORES */
  /* add semaphores, ... */
  /* USER CODE END RTOS_SEMAPHORES */

  /* USER CODE BEGIN RTOS_TIMERS */
  /* start timers, add new ones, ... */
  /* USER CODE END RTOS_TIMERS */

  /* USER CODE BEGIN RTOS_QUEUES */
  /* add queues, ... */
  /* USER CODE END RTOS_QUEUES */

  /* Create the thread(s) */
  /* creation of defaultTask */
  defaultTaskHandle = osThreadNew(StartDefaultTask, NULL, &defaultTask_attributes);

  /* creation of LED_TASK */
  LED_TASKHandle = osThreadNew(LEDTask, NULL, &LED_TASK_attributes);

  /* creation of Chassis_TASK */
  Chassis_TASKHandle = osThreadNew(ChassisTask, NULL, &Chassis_TASK_attributes);

  /* creation of Communicatetask */
  CommunicatetaskHandle = osThreadNew(CommunicateTask, NULL, &Communicatetask_attributes);

  /* creation of LostCountertask */
  LostCountertaskHandle = osThreadNew(LostCounterTask, NULL, &LostCountertask_attributes);

  /* creation of DataTest_Task */
  DataTest_TaskHandle = osThreadNew(DataTestTask, NULL, &DataTest_Task_attributes);

  /* creation of DrawUI_Task */
  DrawUI_TaskHandle = osThreadNew(DrawUITask, NULL, &DrawUI_Task_attributes);

  /* creation of SuperC_Task */
  SuperC_TaskHandle = osThreadNew(SuperCTask, NULL, &SuperC_Task_attributes);

  /* creation of Remote_Task */
  Remote_TaskHandle = osThreadNew(RemoteTask, NULL, &Remote_Task_attributes);

  /* creation of ImuTask */
  ImuTaskHandle = osThreadNew(GyroTask, NULL, &ImuTask_attributes);

  /* USER CODE BEGIN RTOS_THREADS */
  /* add threads, ... */
  /* USER CODE END RTOS_THREADS */

  /* USER CODE BEGIN RTOS_EVENTS */
  /* add events, ... */
  /* USER CODE END RTOS_EVENTS */

}

/* USER CODE BEGIN Header_StartDefaultTask */
/**
  * @brief  Function implementing the defaultTask thread.
  * @param  argument: Not used
  * @retval None
  */
/* USER CODE END Header_StartDefaultTask */
void StartDefaultTask(void *argument)
{
  /* USER CODE BEGIN StartDefaultTask */
  /* Infinite loop */
  for(;;)
  {
    osDelay(1);
  }
  /* USER CODE END StartDefaultTask */
}

/* USER CODE BEGIN Header_LEDTask */
/**
* @brief Function implementing the LED_TASK thread.
* @param argument: Not used
* @retval None
*/
/* USER CODE END Header_LEDTask */
__weak void LEDTask(void *argument)
{
  /* USER CODE BEGIN LEDTask */
  /* Infinite loop */
  for(;;)
  {
    osDelay(1);
  }
  /* USER CODE END LEDTask */
}

/* USER CODE BEGIN Header_ChassisTask */
/**
* @brief Function implementing the Chassis_TASK thread.
* @param argument: Not used
* @retval None
*/
/* USER CODE END Header_ChassisTask */
__weak void ChassisTask(void *argument)
{
  /* USER CODE BEGIN ChassisTask */
  /* Infinite loop */
  for(;;)
  {
    osDelay(1);
  }
  /* USER CODE END ChassisTask */
}

/* USER CODE BEGIN Header_CommunicateTask */
/**
* @brief Function implementing the Communicatetask thread.
* @param argument: Not used
* @retval None
*/
/* USER CODE END Header_CommunicateTask */
__weak void CommunicateTask(void *argument)
{
  /* USER CODE BEGIN CommunicateTask */
  /* Infinite loop */
  for(;;)
  {
    osDelay(1);
  }
  /* USER CODE END CommunicateTask */
}

/* USER CODE BEGIN Header_LostCounterTask */
/**
* @brief Function implementing the LostCountertask thread.
* @param argument: Not used
* @retval None
*/
/* USER CODE END Header_LostCounterTask */
__weak void LostCounterTask(void *argument)
{
  /* USER CODE BEGIN LostCounterTask */
  /* Infinite loop */
  for(;;)
  {
    osDelay(1);
  }
  /* USER CODE END LostCounterTask */
}

/* USER CODE BEGIN Header_DataTestTask */
/**
* @brief Function implementing the DataTest_Task thread.
* @param argument: Not used
* @retval None
*/
/* USER CODE END Header_DataTestTask */
__weak void DataTestTask(void *argument)
{
  /* USER CODE BEGIN DataTestTask */
  /* Infinite loop */
  for(;;)
  {
    osDelay(1);
  }
  /* USER CODE END DataTestTask */
}

/* USER CODE BEGIN Header_DrawUITask */
/**
* @brief Function implementing the DrawUI_Task thread.
* @param argument: Not used
* @retval None
*/
/* USER CODE END Header_DrawUITask */
__weak void DrawUITask(void *argument)
{
  /* USER CODE BEGIN DrawUITask */
  /* Infinite loop */
  for(;;)
  {
    osDelay(1);
  }
  /* USER CODE END DrawUITask */
}

/* USER CODE BEGIN Header_SuperCTask */
/**
* @brief Function implementing the SuperC_Task thread.
* @param argument: Not used
* @retval None
*/
/* USER CODE END Header_SuperCTask */
__weak void SuperCTask(void *argument)
{
  /* USER CODE BEGIN SuperCTask */
  /* Infinite loop */
  for(;;)
  {
    osDelay(1);
  }
  /* USER CODE END SuperCTask */
}

/* USER CODE BEGIN Header_RemoteTask */
/**
* @brief Function implementing the Remote_Task thread.
* @param argument: Not used
* @retval None
*/
/* USER CODE END Header_RemoteTask */
__weak void RemoteTask(void *argument)
{
  /* USER CODE BEGIN RemoteTask */
  /* Infinite loop */
  for(;;)
  {
    osDelay(1);
  }
  /* USER CODE END RemoteTask */
}

/* USER CODE BEGIN Header_GyroTask */
/**
* @brief Function implementing the ImuTask thread.
* @param argument: Not used
* @retval None
*/
/* USER CODE END Header_GyroTask */
__weak void GyroTask(void *argument)
{
  /* USER CODE BEGIN GyroTask */
  /* Infinite loop */
  for(;;)
  {
    osDelay(1);
  }
  /* USER CODE END GyroTask */
}

/* Private application code --------------------------------------------------*/
/* USER CODE BEGIN Application */

/* USER CODE END Application */

